package com.ruoyi.swla2.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.swla2.domain.TerminalsWq;
import com.ruoyi.swla2.service.ITerminalsWqService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 水质检测仪档案Controller
 *
 * @author gdqt
 * @date 2024-09-09
 */
@RestController
@RequestMapping("/swla2/terminalsWq")
public class TerminalsWqController extends BaseController {
    @Autowired
    private ITerminalsWqService terminalsWqService;

    /**
     * 查询水质检测仪档案列表
     */
    @PreAuthorize("@ss.hasAnyPermi('swla2:terminalsWq:list,device:terminalsInfo:list')")
    @GetMapping("/listAll")
    public AjaxResult listAll(TerminalsWq terminalsWq) {
        List<TerminalsWq> list = terminalsWqService.selectTerminalsWqList(terminalsWq);
        return success(list);
    }

    /**
     * 查询水质检测仪档案列表
     */
    @PreAuthorize("@ss.hasPermi('swla2:terminalsWq:list')")
    @GetMapping("/list")
    public TableDataInfo list(TerminalsWq terminalsWq) {
        startPage();
        List<TerminalsWq> list = terminalsWqService.selectTerminalsWqList(terminalsWq);
        return getDataTable(list);
    }

    /**
     * 导出水质检测仪档案列表
     */
    @PreAuthorize("@ss.hasPermi('swla2:terminalsWq:export')")
    @Log(title = "水质检测仪档案", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TerminalsWq terminalsWq) {
        List<TerminalsWq> list = terminalsWqService.selectTerminalsWqList(terminalsWq);
        ExcelUtil<TerminalsWq> util = new ExcelUtil<TerminalsWq>(TerminalsWq.class);
        util.exportExcel(response, list, "水质检测仪档案数据");
    }

    /**
     * 获取水质检测仪档案详细信息
     */
    @PreAuthorize("@ss.hasPermi('swla2:terminalsWq:query')")
    @GetMapping(value = "/{ID}")
    public AjaxResult getInfo(@PathVariable("ID") Long ID) {
        return success(terminalsWqService.selectTerminalsWqByID(ID));
    }

    /**
     * 新增水质检测仪档案
     */
    @PreAuthorize("@ss.hasPermi('swla2:terminalsWq:add')")
    @Log(title = "水质检测仪档案", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TerminalsWq terminalsWq) {
        return toAjax(terminalsWqService.insertTerminalsWq(terminalsWq));
    }

    /**
     * 修改水质检测仪档案
     */
    @PreAuthorize("@ss.hasPermi('swla2:terminalsWq:edit')")
    @Log(title = "水质检测仪档案", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TerminalsWq terminalsWq) {
        return toAjax(terminalsWqService.updateTerminalsWq(terminalsWq));
    }

    /**
     * 删除水质检测仪档案
     */
    @PreAuthorize("@ss.hasPermi('swla2:terminalsWq:remove')")
    @Log(title = "水质检测仪档案", businessType = BusinessType.DELETE)
    @DeleteMapping("/{IDs}")
    public AjaxResult remove(@PathVariable Long[] IDs) {
        return toAjax(terminalsWqService.deleteTerminalsWqByIDs(IDs));
    }
}
